<?php

class Lessons extends Zend_Db_Table {

    protected $_name = 'jos_elogo_lessons';
    
    public function getScreens($lesson,$order='screen_id ASC') {
        $select = $this->select()->where('lesson_id=:lesson')->bind(array(':lesson'=>$lesson));
        $select->order("$order");
        $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
        if ($adapter) {
            return $adapter;
        } else {
            throw new Zend_Exception('Nie można pokazać uczniów. Nie znaleziono rekordu!');
        }
    }
    
    public function getAll($order='id ASC') {
        $select = $this->select()->where('1');
        $select->order($order);
        $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
        if ($adapter) {
            return $adapter;
        } else {
            throw new Zend_Exception('Nie można pokazać uczniów. Nie znaleziono rekordu!');
        }
    }
    

    public function showInfoUser($id) {
        $select = $this->fetchRow($this->select()
                                ->where('users_id=?', $id));
        if ($select) {
            return $select;
        } else {
            throw new Zend_Exception('Nie można pokazac informacji o uzytkowniku. Nie znaleziono rekordu!');
        }
    }

}
